package com.neusoft.databus.core.loadbalance;

import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory;
import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
import org.springframework.cloud.openfeign.ribbon.RetryableFeignLoadBalancer;

import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.reactive.LoadBalancerCommand.Builder;

/**
 * description
 *
 * @author sunchf
 * @date 2019年2月20日 上午9:17:42
 */
public class StatefulRetryableFeignLoadBalancer extends RetryableFeignLoadBalancer {

    public StatefulRetryableFeignLoadBalancer(ILoadBalancer lb, IClientConfig clientConfig,
            ServerIntrospector serverIntrospector, LoadBalancedRetryFactory loadBalancedRetryFactory) {
        super(lb, clientConfig, serverIntrospector, loadBalancedRetryFactory);
    }

    @Override
    protected void customizeLoadBalancerCommandBuilder(RibbonRequest request, IClientConfig config,
            Builder<RibbonResponse> builder) {
        super.customizeLoadBalancerCommandBuilder(request, config, builder);
        builder.withServerLocator(request.getRequest());
    }

}
